3.3.1 Rectify

Rectify reorganizes parenthesized subexpressions into left-to-right subexpressions. For example, .{a+(b+c)} and Rectify produce a+b+c.

Parenthesized subexpressions occur when text input is parsed. They can also arise from various transformations. .{a+b}+c and produce the unrectified expression c+(a+b).

For example, to gather the terms in xn from .{a⋅x^2}+b⋅x-2⋅c⋅x+d⋅x^2, the first term can be moved right to achieve b⋅x+.{a⋅x^2}-2⋅c⋅x+d⋅x^2 and moved again to achieve b⋅x-2⋅c⋅x+.{a⋅x^2}+d⋅x^2; then the first two terms can be selected for factoring. However, the last two terms cannot be selected. One way to rewrite the terms is to select the first two and move them right twice to produce an unrectified expression a⋅x^2+.{d⋅x^2}+(b⋅x-2⋅c⋅x). Now the first two terms or the last two terms can be selected and a transformation like Factor can be performed.